package ui;

/**
 * JPanel AddCustomer
 * 
 * @author XA9
 * 
 */

import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.JTextField;

public class AddCustomer extends JPanel {
	private JLabel lblAddCustomer;
	private JLabel lblXA9;
	private JLabel lblLogo;
	private JButton btnReturn;
	private JTextField tfFirstname;
	private JTextField tfLastname;
	private JTextField tfCpr;
	private JTextField tfLoginId;
	private JTextField tfPassword;
	private JLabel lblFirstname;
	private JLabel lblLastname;
	private JLabel lblCpr;
	private JLabel lblLoginid;
	private JLabel lblPassword;
	private JButton btnAddCustomer;
	private JLabel lblPleaseEnterDetails;

	/**
	 * Create the panel.
	 */
	public AddCustomer() {
		setBackground(UIManager.getColor("Label.background"));
		setLayout(null);

		lblAddCustomer = new JLabel("Add new customer");
		lblAddCustomer.setOpaque(true);
		lblAddCustomer.setBackground(UIManager.getColor("Label.background"));
		lblAddCustomer.setHorizontalAlignment(SwingConstants.CENTER);
		lblAddCustomer.setForeground(UIManager.getColor("menuText"));
		lblAddCustomer.setFont(new Font("Eurostile", Font.BOLD, 22));
		lblAddCustomer.setBounds(0, 94, 735, 28);
		add(lblAddCustomer);

		lblXA9 = new JLabel("\u00A92013 CBS HA.IT (Gruppe XA-9)\t\t ");
		lblXA9.setForeground(UIManager.getColor("Button.darkShadow"));
		lblXA9.setBackground(UIManager.getColor("Button.darkShadow"));
		lblXA9.setHorizontalAlignment(SwingConstants.CENTER);
		lblXA9.setFont(new Font("Eurostile", Font.PLAIN, 11));
		lblXA9.setBounds(0, 550, 735, 50);
		add(lblXA9);

		btnReturn = new JButton("Return to main menu");
		btnReturn.setFont(new Font("Eurostile", Font.PLAIN | Font.BOLD, 13));
		btnReturn.setForeground(UIManager.getColor("CheckBox.select"));
		btnReturn.setBounds(190, 362, 185, 45);
		add(btnReturn);

		lblLogo = new JLabel("");
		lblLogo.setIcon(new ImageIcon(
				"/Users/martinotto-sidelmann/Desktop/Zombium.png"));
		lblLogo.setBounds(530, 12, 200, 70);
		add(lblLogo);

		tfFirstname = new JTextField();
		tfFirstname.setToolTipText("Add customers firstname\n");
		tfFirstname.setFont(new Font("Eurostile", Font.PLAIN, 13));
		tfFirstname.setBounds(190, 165, 185, 33);
		add(tfFirstname);
		tfFirstname.setColumns(10);

		tfLastname = new JTextField();
		tfLastname.setToolTipText("Add customers lastname");
		tfLastname.setFont(new Font("Eurostile", Font.PLAIN, 13));
		tfLastname.setColumns(10);
		tfLastname.setBounds(405, 165, 185, 33);
		add(tfLastname);

		tfCpr = new JTextField();
		tfCpr.setToolTipText("Add customers CPR-number");
		tfCpr.setFont(new Font("Eurostile", Font.PLAIN, 13));
		tfCpr.setColumns(10);
		tfCpr.setBounds(405, 210, 185, 33);
		add(tfCpr);

		tfLoginId = new JTextField();
		tfLoginId.setToolTipText("Add loginId to customer");
		tfLoginId.setFont(new Font("Eurostile", Font.PLAIN, 13));
		tfLoginId.setColumns(10);
		tfLoginId.setBounds(190, 210, 185, 33);
		add(tfLoginId);

		tfPassword = new JTextField();
		tfPassword.setToolTipText("Add password to customer");
		tfPassword.setFont(new Font("Eurostile", Font.PLAIN, 13));
		tfPassword.setColumns(10);
		tfPassword.setBounds(190, 260, 185, 33);
		add(tfPassword);

		lblFirstname = new JLabel("Firstname:");
		lblFirstname.setFont(new Font("Eurostile", Font.BOLD, 13));
		lblFirstname.setBounds(193, 145, 200, 33);
		add(lblFirstname);

		lblLastname = new JLabel("Lastname:");
		lblLastname.setFont(new Font("Eurostile", Font.BOLD, 13));
		lblLastname.setBounds(408, 145, 200, 33);
		add(lblLastname);

		lblCpr = new JLabel("CPR:");
		lblCpr.setFont(new Font("Eurostile", Font.BOLD, 13));
		lblCpr.setBounds(408, 190, 200, 33);
		add(lblCpr);

		lblLoginid = new JLabel("LoginId:");
		lblLoginid.setFont(new Font("Eurostile", Font.BOLD, 13));
		lblLoginid.setBounds(193, 190, 200, 33);
		add(lblLoginid);

		lblPassword = new JLabel("Password:");
		lblPassword.setFont(new Font("Eurostile", Font.BOLD, 13));
		lblPassword.setBounds(193, 240, 200, 33);
		add(lblPassword);

		btnAddCustomer = new JButton("Add customer");
		btnAddCustomer.setFont(new Font("Eurostile", Font.BOLD, 13));
		btnAddCustomer.setBounds(405, 255, 185, 45);
		add(btnAddCustomer);

		lblPleaseEnterDetails = new JLabel("Please enter details to add customer");
		lblPleaseEnterDetails.setHorizontalAlignment(SwingConstants.CENTER);
		lblPleaseEnterDetails.setForeground(Color.BLACK);
		lblPleaseEnterDetails.setFont(new Font("Eurostile", Font.PLAIN, 15));
		lblPleaseEnterDetails.setBounds(0, 122, 735, 16);
		add(lblPleaseEnterDetails);

	}

	/**
	 * Returns text from JTextfield tfFirstname
	 * 
	 * @return String firstname
	 */
	public String getTfFirstname() {
		return tfFirstname.getText();
	}

	/**
	 * Returns text from JTextfield tfLastname
	 * 
	 * @return String lastname
	 */
	public String getTfLastname() {
		return tfLastname.getText();
	}

	/**
	 * Returns text from JTextfield tfCpr
	 * 
	 * @return String cpr
	 */
	public String getTfCpr() {

		return tfCpr.getText();
	}

	/**
	 * Returns text from JTextfield tfLoginI
	 * 
	 * @return String loginid
	 */
	public String getTfLoginId() {

		return tfLoginId.getText();
	}

	/**
	 * Returns text from JTextfield tfPassword
	 * 
	 * @return String password
	 */
	public String getTfPassword() {

		return tfPassword.getText();
	}

	/**
	 * Returns JButton
	 * 
	 * @return btnAddCustomer
	 */
	public JButton getBtnAddCustomer() {
		return btnAddCustomer;
	}

	/**
	 * Returns JButton
	 * 
	 * @return btnReturn
	 */
	public JButton getBtnReturn() {
		return btnReturn;
	}

	/**
	 * Clear fields of JTextfields
	 * 
	 */
	public void clearFields() {
		tfFirstname.setText("");
		tfLastname.setText("");
		tfCpr.setText("");
		tfLoginId.setText("");
		tfPassword.setText("");
	}

	/**
	 * Add ActionListener to JButtons
	 * 
	 * @param ActionListener l
	 * 
	 */
	public void addActionListener(ActionListener l) {
		btnReturn.addActionListener(l);
		btnAddCustomer.addActionListener(l);

	}
}
